package com.cn.ant.modules.wechat.service;

import com.cn.ant.common.persistence.Page;
import com.cn.ant.common.service.BaseService;
import com.cn.ant.modules.wechat.dao.SubscribeMapper;
import com.cn.ant.modules.wechat.entity.Subscribe;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;
/**
 * 关注消息Service
 * @author AntDream
 * @version 2015-03-23
 */
@Component
@Transactional(readOnly = true)
public class SubscribeService extends BaseService {

	@Autowired
	private SubscribeMapper subscribeMapper;
	
	public Subscribe get(String id) {
		return subscribeMapper.get(id);
	}
	
	public Page<Subscribe> find(Page<Subscribe> page, Map<String,Object> param) {
        param.put("startIdx", page.getFirstResult());
        param.put("pageSize", page.getPageSize());
        page.setList(subscribeMapper.query(param));
        page.setCount(subscribeMapper.queryCount(param));
        return page;
	}

    public List<Subscribe> queryForList(Map<String, Object> param) {
        return subscribeMapper.query(param);
    }


	@Transactional(readOnly = false)
	public void save(Subscribe subscribe) {
		subscribeMapper.insert(subscribe);
	}
	
	@Transactional(readOnly = false)
	public void update(Subscribe subscribe) {
		subscribeMapper.update(subscribe);
	}
	
	@Transactional(readOnly = false)
	public void delete(String id) {
		subscribeMapper.delete(id);
	}
	
}
